package com.vains.client.impl;

import com.vains.client.AuthClient;
import com.vains.enumeration.ResultEnum;
import com.vains.io.JsonUtils;
import com.vains.system.model.Result;
import com.vains.system.util.ResultUtils;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 通过feign调用auth服务异常时调用该实现
 *
 * @see com.vains.client.AuthClient
 * @author vains
 */
@Component
public class AuthClientBack implements AuthClient {

    @Override
    public Result<Boolean> hasAuth(String url, String accessToken) {
        return new Result<>(ResultEnum.ERROR.getCode(), false, "请求失败, auth服务状态异常!", false);
    }

    @Override
    public Map<String, Object> checkToken(String value) {
        Result<String> error = ResultUtils.error("请求失败, auth服务状态异常!");
        return JsonUtils.objectCovertToObject(error, Map.class, String.class, Object.class);
    }

}
